package com.mcu32.bright.controller;


import com.mcu32.bright.model.Result;
import com.mcu32.bright.model.bo.DevicePropertyBo;
import com.mcu32.bright.model.bo.DevicePropertyQueryBo;
import com.mcu32.bright.service.OneNetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * OneNet应用开发类接口
 * @author wuzhiwei
 */
@RestController
@RequestMapping("/OneNET")
public class OneNetController {

    @Autowired
    private OneNetService oneNetService;

    /**
     * 创建设备
     * @param deviceName
     * @return
     */
    @PostMapping("/createDevice")
    public Result createDevice(String deviceName){
        return oneNetService.createDevice(deviceName);
    }

    /**
     * 设置设备属性
     * @return
     */
    @PostMapping("/setDeviceProperty")
    public Result setDeviceProperty(@RequestBody DevicePropertyBo devicePropertyBo){
        return oneNetService.setDeviceProperty(devicePropertyBo);
    }

    /**
     * 获取设备最新数据(设备上传的最近一条数据)
     * @return
     */
    @GetMapping("/queryDeviceProperty")
    public Result queryDeviceProperty(@RequestBody DevicePropertyBo devicePropertyBo){
        return oneNetService.queryDeviceProperty(devicePropertyBo);
    }

    /**
     * 获取设备实时数据(设备当前实时返回的数据)
     * @return
     */
    @PostMapping("/queryDevicePropertyDetail")
    public Result queryDevicePropertyDetail(@RequestBody DevicePropertyQueryBo devicePropertyQueryBo){
        return oneNetService.queryDevicePropertyDetail(devicePropertyQueryBo);
    }


}
